home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Pascal Super Library
/
Pascal Super Library (CW International)(1997).bin
/
DELPHI32
/
COMPNENT
/
ISAMEXPT
/
DBF2ISAM.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1996-04-04
|
4KB
|
153 lines
unit Dbf2isam;
interface
uses WinTypes, WinProcs, Classes, Graphics, Forms, Controls, Buttons,
StdCtrls, Isamtabl, Gauges, DB, DBTables, ExtCtrls,
U_DbTool, Grids, DBGrids;
type
DBASEImportProc = Procedure(var DATA; DBTable: TTable; ISTable: TIsamTable);
TImportDlg = class(TForm)
CancelBtn: TBitBtn;
Bevel1: TBevel;
Table1: TTable;
Gauge1: TGauge;
IsamTable1: TIsamTable;
StartBttn: TBitBtn;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
GroupBox1: TGroupBox;
aktualRadio: TRadioButton;
appendradio: TRadioButton;
appendandupdateradio: TRadioButton;
procedure CancelBtnClick(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure StartBttnClick(Sender: TObject);
private
{ Private declarations }
public
FieldGetProc: DBASEImportProc;
Data,Dup : Pointer;
end;
var
ImportDlg: TImportDlg;
Procedure DBase2Isam(aParent: TForm;
IsamTable: TIsamTable;
DBASETableName: String;
AliasName: String;
FieldGet: DBASEImportProc);
implementation
Uses SysUtils, UToolDll, Filer;
{$R *.DFM}
procedure TImportDlg.CancelBtnClick(Sender: TObject);
begin
Close;
end;
Procedure DBase2Isam(aParent: TForm;
IsamTable: TIsamTable;
DBASETableName: String;
AliasName: String;
FieldGet: DBASEImportProc);
var AktDir: String;
begin
if Pos('.',DBaseTableName) > 0 then DBaseTableName:= Copy(DBaseTableName,1,Pos('.',DBaseTableName)-1);
DBaseTableName:= DBaseTableName + '.DBF';
AktDir:= ExtractFilePath(Application.ExeName);
Check_Alias(AliasName,AktDir);
ImportDlg:= TImportDlg.Create(aParent);
Try
ImportDlg.IsamTable1:= IsamTable;
ImportDlg.Table1.DataBaseName:= AliasName;
ImportDlg.Table1.TableName:= DBaseTableName;
ImportDlg.FieldGetProc:= FieldGet;
ImportDlg.ShowModal;
Finally
ImportDlg.Free;
end;
end;
procedure TImportDlg.FormDestroy(Sender: TObject);
begin
FreeMem(Data,IsamTable1.RecSize);
FreeMem(Dup,IsamTable1.RecSize);
if Table1.Active then Table1.Close;
end;
procedure TImportDlg.FormCreate(Sender: TObject);
begin
FieldGetProc:= NIL;
if Sprache = 1 then begin
GroupBox1.Caption:= 'Options';
AktualRadio.Caption:= 'update only';
AppendRadio.Caption:= 'append new only';
AppendAndUpdateRadio.Caption:= 'append and update';
CancelBtn.Caption:= 'End';
end;
end;
procedure TImportDlg.FormShow(Sender: TObject);
begin
GetMem(Data,IsamTable1.RecSize);
GetMem(Dup,IsamTable1.RecSize);
Table1.Open;
end;
procedure TImportDlg.StartBttnClick(Sender: TObject);
var i,RCount: Longint;
Altprogress,NeuProgress: Integer;
Key1: IsamKeyStr;
begin
if Table1.Active then begin
if IsamTable1.Active then begin
IsamTable1.KeyNo:= 1;
RCount:= Table1.RecordCount;
Table1.First;
i:= 0;
AltProgress:= 0;
IsamOk:= True;
Repeat
if IsamOk then begin
FieldGetProc(DATA^,Table1,IsamTable1);
Key1:= IsamTable1.Key_Proc(Data^,IsamTable1.KeyNo);
if IsamTable1.FindKey(Data^,Data^,Key1) then begin
if (AppendAndUpdateRadio.Checked) or (AktualRadio.Checked) then
IsamTable1.UpdateRecord(DATA^,DATA^);
end
else begin
if (AppendAndUpdateRadio.Checked) or (AppendRadio.Checked) then
IsamTable1.Append(DATA^,DATA^);
end;
Table1.Next;
end;
Inc(i);
NeuProgress:= Round((i/RCount)*100);
if AltProgress <> NeuProgress then begin
AltProgress:= NeuProgress;
Gauge1.Progress:= NeuProgress;
end;
Until (Table1.Eof) or (i = rCount);
end
else begin
if Sprache = 1 then Errorwindow('Isamtable is not opened','')
else Errorwindow('Isamtabelle ist nicht ge÷ffnet','');
end;
end
else begin
if Sprache = 1 then Errorwindow('Isamtable is not opened','')
else Errorwindow('DBASE-Tabelle ist nicht ge÷ffnet','');
end;
end;
end.